import { defaultListRequestParams } from '@/config';
import api from '@/services/customer/group-customer';

export type GroupCustomerManagement = GroupCustomerManagementApi.ListResponse;
export const getFilterList = async () => {
  const res = await api.getFilterList();
  return res.data;
};
export const getList = async (params: GroupCustomerManagementApi.ListParams) => {
  const res = await api.getList<GroupCustomerManagement>(params);
  const tableData: Requestor.TableFormatedData<GroupCustomerManagement> = {
    data: res.listData,
    current: res.page + 1,
    pageSize: res.limit,
    total: res.count,
    success: res.success,
  };

  return tableData;
};
export const getAllList = async () => {
  const requestParams: GroupCustomerManagementApi.ListParams = {
    ...defaultListRequestParams,
    page: 0,
    limit: 500,
  };
  const res = await api.getList<GroupCustomerManagement>(requestParams);
  return res.listData;
};

export default {
  getFilterList,
  getList,
  getAllList,
};
